package com.example.juc.big_talk_concurrent.chapter7.article2;

import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Test3 {
    // 创建线程池
    static ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
    public static void main(String[] args) {
        // 创建任务
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("执行任务" + new Date());
            }
        };

        System.out.println("10 秒后开始执行线程池服务" + new Date());
        scheduledThreadPool.schedule(runnable, 10, TimeUnit.SECONDS);
    }
}
